﻿using System;
using System.Windows;
using System.Windows.Controls;
using GpgApi;

namespace WgpgGUI
{
    public partial class DialogAddIdentification : Window
    {
        public DialogAddIdentification(Window owner)
        {
            Owner = owner;
            InitializeComponent();
        }

        public Name FullName
        {
            get { return new Name(fullname_textbox.Text.Trim()); }
        }

        public Email Email
        {
            get { return new Email(email_textbox.Text.Trim()); }
        }

        public String Comment
        {
            get { return comment_textbox.Text.Trim(); }
        }

        private void Add(Object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            Close();
        }

        private void TextChanged(Object sender, TextChangedEventArgs e)
        {
            String fullName = fullname_textbox.Text.Trim();
            String email = email_textbox.Text.Trim();
            add_button.IsEnabled = GpgApi.Name.IsValid(fullName) && Email.IsValid(email);
        }
    }
}
